#include<bits/stdc++.h>
using namespace std;
const int len=1e5+5;
struct car{
    int s,v,a;
}cr[len];
int T,n,m,L,V,cnt,ce,chk[len];
bool f0=1,f1=1,f2=1;
int inline read(){
    int x=0,f=1;
    char ch=getchar();
    while('0'>ch||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while('0'<=ch&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
bool f[len],cf[len],t[len];
void dfs(int dep){
    if(dep>=m+1){
        int tce=0;
        memset(t,0,sizeof(t));
        for(int j=1;j<=m;j++){
            if(!f[j]){
                tce++;
                continue;
            }
            for(int i=1;i<=n;i++){
                if(chk[j]-cr[i].s<0||cr[i].v*cr[i].v+2*cr[i].a*(chk[j]-cr[i].s)<0) continue;
                double tv=sqrt(cr[i].v*cr[i].v+2*cr[i].a*(chk[j]-cr[i].s));
                if(tv>V){
                    t[i]=1;
                }
            }
        }
        for(int i=1;i<=n;i++){
            if(t[i]!=cf[i]) return;
        }
        ce=max(ce,tce);
        return;
    }
    f[dep]=0;
    dfs(dep+1);
    f[dep]=1;
    dfs(dep+1);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--){
        cnt=0;
        n=read(),m=read(),L=read(),V=read();
        ce=0;
        for(int i=1;i<=n;i++){
            cf[i]=0;
            cr[i].s=read(),cr[i].v=read(),cr[i].a=read();
            if(cr[i].a!=0) f0=0;
            if(cr[i].a<=0) f1=0;
            if(cr[i].a>=0) f2=0;
        }
        for(int i=1;i<=m;i++){
            f[i]=0;
            chk[i]=read();
        }
        if(f1||f0){
            for(int i=1;i<=n;i++){
                if(chk[m]-cr[i].s<0) continue;
                double tv=sqrt(cr[i].v*cr[i].v+2*cr[i].a*(chk[m]-cr[i].s));
                if(tv>V){
                    cnt++;
                }
            }
            if(cnt!=0) cout<<cnt<<' '<<m-1<<'\n';
            else cout<<cnt<<' '<<m<<'\n';
        }
        else if(n<=20&&m<=20){
            for(int j=1;j<=m;j++){
                for(int i=1;i<=n;i++){
                    if(chk[j]-cr[i].s<0||cr[i].v*cr[i].v+2*cr[i].a*(chk[j]-cr[i].s)<0) continue;
                    double tv=sqrt(cr[i].v*cr[i].v+2*cr[i].a*(chk[j]-cr[i].s));
                    if(tv>V){
                        if(cf[i]==0) cnt++;
                        cf[i]=1;
                    }
                }
            }
            dfs(1);
            cout<<cnt<<' '<<ce<<'\n';
        }
        else cout<<0<<' '<<m<<'\n';
    }
    return 0;
}
